package com.xing.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.xing.cmn.entity.Dict;
import com.xing.cmn.mapper.DictMapper;
import com.xing.hospital.model.vo.cmn.DictEevo;
import org.springframework.beans.BeanUtils;

/**
 * @Author: xingfuhao
 * @Date: 2022/05/20/11:19
 */
//AnalysisEventListener:分析事件监听器
public class DictListener extends AnalysisEventListener<DictEevo> {

    private DictMapper dictMapper;

    public DictListener(DictMapper dictMapper) {
        this.dictMapper = dictMapper;
    }

    //调用
    //一行一行读取
    @Override
    public void invoke(DictEevo dictEevo, AnalysisContext analysisContext) {

        //调用方法添加数据库
        Dict dict = new Dict();
        BeanUtils.copyProperties(dictEevo,dict);
        dictMapper.insert(dict);
    }

    //执行完后的所有分析
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }

}
